﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace QuanLyThuNgan
{
    public class BaFeeMstDAO
    {
        public string m_Insert_(int stt, string sobn, string ngay, string sohs, decimal sotien, string madv, string GhiChuUni, int idbacsi, string madvpk, string ChanDoanUni, int IDCaThuNgan, int IDLoaiPhieu, decimal TongSoTien,string ghichu,string chandoan,int bhyt,decimal BHYTThanhToan,int IDNguoiNhap)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_BaFeeMst_Insert {0},'{1}','{2}','{3}',{4},'{5}',N'{6}',{7},'{8}',N'{9}',{10},{11},{12},'{13}','{14}',{15},{16},{17}",
            stt, sobn,ngay,sohs,sotien,madv,GhiChuUni,idbacsi,madvpk,ChanDoanUni,IDCaThuNgan,IDLoaiPhieu,TongSoTien,ghichu,chandoan,bhyt,BHYTThanhToan,IDNguoiNhap);
            return _sql;
        }
        public string m_Update_(int stt, string sobn, string ngay, string sohs, decimal sotien, string madv, string GhiChuUni, int idbacsi, string madvpk, string ChanDoanUni, int IDCaThuNgan, int IDLoaiPhieu, decimal TongSoTien, string ghichu, string chandoan, int bhyt, decimal BHYTThanhToan, int IDNguoiNhap)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_BaFeeMst_Update {0},'{1}','{2}','{3}',{4},'{5}',N'{6}',{7},'{8}',N'{9}',{10},{11},{12},'{13}','{14}',{15},{16},{17}",
              stt, sobn, ngay, sohs, sotien, madv, GhiChuUni, idbacsi, madvpk, ChanDoanUni, IDCaThuNgan, IDLoaiPhieu, TongSoTien, ghichu, chandoan, bhyt, BHYTThanhToan, IDNguoiNhap);
            return _sql;
        }
        public string m_Delete_(string sobn)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_BaFeeMst_Delete '{0}'",sobn);
            return _sql;
        }
        public object m_SoBN(string madonvi,int loai)//=1 la can lam san
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_BaFeeMst_sobn '{0}',{1}",madonvi,loai);
            return Uit.it_SQL.ExecuteScalar(_sql,null);
        }
        public object m_STT(string madonvi, string ngay)//la don vi thuc hien thu tien
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_Bafeemst_STT '{0}','{1}'", madonvi, ngay);
            return Uit.it_SQL.ExecuteScalar(_sql, null);
        }
        public DataTable m_STT_SoBN_IDThuNgan(int idnguoinhap,string ngay,string madv_rachidinh)//madovi cua dich vu 
        { 
            string _sql = string.Format("exec dbo.usp_ThuNgan_SBN_IDCaThuNgan_ISTT {0},'{1}','{2}'",idnguoinhap,ngay,madv_rachidinh);
            return Uit.it_SQL.getDataTable(_sql);
        }
        public DataTable m_STT_SoBN_IDThuNgan_noitru(int idnguoinhap,string ngay,string madonvi,string maphkham)//madv don vi thu tien,  Madonvi: ma don vi ra chi dinh cam lam sang 
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_SBN_IDCaThuNgan_ISTT_noitru {0},'{1}','{2}','3'", idnguoinhap, ngay, madonvi,maphkham);
            return Uit.it_SQL.getDataTable(_sql);
        }
        
        public DataSet m_LoadDSPhieuNhapTrucTiep(string mangsbn)
        {
            if(mangsbn.Length==4)
               mangsbn="'('''')'";
            string _sql = string.Format("exec dbo.usp_ThuNgan_LoadDanhSachPhieuDichVuNhapTrucTiep {0}", mangsbn);
            return Uit.it_SQL.getDataSet(_sql,true);

        }
        public object m_SoBN_KO_CLS(int loaiphieu)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_SOBN {0}", loaiphieu);
            return Uit.it_SQL.ExecuteScalar(_sql,null);
        }
        public object m_SoBN_KO_CLS_noitru(int loaiphieu,string maphkham)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_SOBN_noitru {0},'{1}'", loaiphieu,maphkham);
            return Uit.it_SQL.ExecuteScalar(_sql, null);
        }
        public string m_Update_mst(string chuoi)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_BafeeMst_UpdateTuDong {0}", chuoi);
            return _sql;
        }
        public string m_Delete_group(string loai, string sobn)
        {
            string _sql = string.Format("exec dbo.usp_ThuNgan_BafeeMst_Delete_group '{0}','{1}'", loai, sobn);
            return _sql;
        }
    }
}
